package org.example;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;
import io.reactivex.internal.schedulers.ComputationScheduler;
import org.example.commend.t1.Node;
import org.example.commend.t1.TBean;
import org.example.commend.t2.T2;
import org.example.commend.t2.Tb2;
import org.example.commend.t3.T1;
import org.example.commend.t4.Bean;

import java.util.*;
import java.util.stream.Collectors;

public class Main {

    private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();


    public static void main(String[] args) {

//        TBean tBean = new TBean();
//
//        Node<Integer> node = new Node<>(tBean::setAge,
//                new Node<>(tBean::setName, null));
//        node.accept(11);
//        System.out.println(tBean);

//        T2.of(new Tb2())
//                .next();

//        boolean[] execute = {true, false, true};
//        boolean[] response = {true, true};
//        boolean[] result = new boolean[3];
//        for (int i = 0; i < execute.length; i++) {
//            boolean responseI;
//            try {
//                responseI = response[i];
//            } catch (Exception e) {
//                responseI = false;
//            }
//            result[i] = execute[i] & responseI;
//        }
//        System.out.println(Arrays.toString(result));

//        byte b = 0b0000000;
//        System.out.println(b & 1);

        //new T1().test3();

//        ArrayList<Bean> beans = new ArrayList<>();
//        for (int i = 0; i < 10; i++) {
//            beans.add(new Bean().setTime(System.currentTimeMillis()));
//        }
//
//        Calendar instance = Calendar.getInstance();
//        Map<Integer, List<Bean>> collect = beans.stream()
//                .collect(Collectors.groupingBy(bean -> {
//                    instance.setTime(new Date(bean.getTime()));
//                    return instance.get(Calendar.HOUR_OF_DAY);
//                }));


//        List<Integer> ints = null;
//        Integer i = Optional.ofNullable(ints)
//                .map(new Function<List<Integer>, Integer>() {
//                    @Override
//                    public Integer apply(List<Integer> integers) {
//                        System.out.println("map");
//                        return integers.size();
//                    }
//                }).orElse(0);
//        System.out.println(i);
//        Optional.of(ints)
//                .ifPresent(System.out::println);
//        Observable<String> o = Observable.create(new ObservableOnSubscribe<String>() {
//            @Override
//            public void subscribe(ObservableEmitter<String> emitter) throws Exception {
//                emitter.onNext("a");
//            }
//        });
//
//        o.subscribeOn(new ComputationScheduler())
//                .map(new Function<String, String>() {
//                    @Override
//                    public String apply(String s) throws Exception {
//                        return null;
//                    }
//                })
//                .subscribe(new Observer<String>() {
//                    @Override
//                    public void onSubscribe(Disposable d) {
//
//                    }
//
//                    @Override
//                    public void onNext(String s) {
//
//                    }
//
//                    @Override
//                    public void onError(Throwable e) {
//
//                    }
//
//                    @Override
//                    public void onComplete() {
//
//                    }
//                });
//


//        String a = "A3352C12";
//        char[] b = new char[8];
//        System.out.println(a.toCharArray());

        System.out.println(8 % 2);
    }

    public static int convertTo32(int la, int lb, int lc, int ld) {
        la = 0XFFFFFF | (la << 24);
        lb = 0XFF00FFFF | (lb << 16);
        lc = 0XFFFF00FF | (lc << 8);
        ld = 0XFFFFFF00 | ld;
        return la & lb & lc & ld;
    }


    public static String bytesToHex(byte[] bytes) {
        char[] hexChars = new char[bytes.length * 3];
        for (int j = 0; j < bytes.length; j++) {
            int v = bytes[j] & 0xFF;
            hexChars[j * 3] = HEX_ARRAY[v >>> 4];
            hexChars[j * 3 + 1] = HEX_ARRAY[v & 0x0F];
            hexChars[j * 3 + 2] = ' ';
        }
        return new String(hexChars);
    }
}